﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch02
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //MessageBox.Show("构造方法");
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            /*
            string msg = "";
            if (radioButton1.Checked)
            {
                msg = radioButton1.Text;
            }
            else
            {
                msg = radioButton2.Text;
            }
            */

            //MessageBox.Show("你选中了" + (radioButton1.Checked? radioButton1: radioButton2).Text);

            //MessageBox.Show("你的爱好是：吃饭、睡觉");


            //MessageBox.Show(panel2.Controls.Count + "");
            //MessageBox.Show(panel2.Controls[2].Text);

            string msg = "你的爱好是：";

            foreach (CheckBox ck in panel2.Controls)
            {
                if (ck.Checked)
                {
                    msg += ck.Text + ",";
                }
            }

            MessageBox.Show(msg.Substring(0,msg.Length-1));
        }
        
    }
}
